import request from '@/api';


/**
 * 读取pin 设置
 * @returns 
 * string sim_status //  connected disconnected no_service connecting sim_locked need_pin need_puk
    bool pin_lock // 是否lock
    number remaining_unlock_trial 允许unlock的次数
    string pin_code // ping 码
    bool auto_unlock // 自动unlock
 */
export function getPinSetting() {
    return request({
        url: '/api/pin/setting',
        method: 'get',
    })
}

/**
 * 设置pin码
 * @param {*} pin_lock 0:不开启 1:开启
 * @param {*} pin_code 6位
 * @param {*} auto_pin 0:不开启 1:开启
 * @returns 
 */
export function setPinSetting(pin_lock,pin_code,auto_pin) {
    return request({
        url: '/api/pin/setting',
        method: 'post',
        data:{
            pin_lock,
            pin_code,
            auto_pin
        }
    })
}

/**
 * 检查pin码
 */
export function verifyPinCode(pin_code) {
    return request({
        url: '/api/pin/verify',
        method: 'post',
        data:{
            pin_code
        }
    })
}

/**
 * 重置pin码
 * @param {*} old_pin_code 
 * @param {*} new_pin_code 
 * @returns 
 */
export function changePinCode(old_pin_code,new_pin_code) {
    return request({
        url: '/api/puk/verify',
        method: 'post',
        data:{
            old_pin_code,
            new_pin_code
        }
    })
}


/**
 * 校验puk码
 * @param {*} pin_code 
 * @param {*} puk_code 
 * @returns 
 */
export function checkPuk(pin_code,puk_code) {
    return request({
        url: '/api/puk/verify',
        method: 'post',
        data:{
            puk_code,
            pin_code
        }
    })
}
